#define _CRT_SECURE_NO_WARNINGS 1
#include <iostream>
#include<vector>
using namespace std;

class Solution {
public:
    long long sumDigitDifferences(vector<int>& nums) {
        int n = nums.size();
        long long res = 0;
        while (nums[0] > 0)
        {
            vector<int> cnt(10);
            for (int i = 0; i < n; ++i)
            {
                ++cnt[nums[i] % 10];
                nums[i] /= 10;
            }
            for (int i = 0; i < 10; ++i)
                res += (long long)(n - cnt[i]) * cnt[i];
        }
        return res / 2;
    }
};

int main() {
    int n, q;
    cin >> n >> q;
    vector<int> nums(n + 1);
    for (int i = 1; i <= n; ++i)
    {
        cin >> nums[i];
    }
    vector<long long> sum(n + 1);
    for (int i = 1; i <= n; ++i)
    {
        sum[i] = sum[i - 1] + nums[i];
    }
    while (q--)
    {
        int n1, n2;
        cin >> n1 >> n2;
        cout << sum[n2] - sum[n1 - 1] << endl;;
    }

    string convert(string s, int numRows) {
        if (numRows < 2) return s;
        vector<string> v(numRows);
        int i = 0, flag = -1;
        for (auto c : s)
        {
            v[i].push_back(c);
            if (i == 0 || i == numRows - 1) flag = -flag;
            i += flag;
        }
        string res;
        for (auto s : v)
            res += s;
        return res;
    }
}